if get_option('enable_tests')
  test_conf_data = configuration_data()
  test_conf_data.set_quoted('TEST_BUILD_TYPES_DIR', fs.as_posix(types_build_dir))
  test_config_h = configure_file(
    input: 'test_config.h.in',
    output: 'test_config.h',
    configuration: test_conf_data,
  )

  subdir('auxiliary')

  tests = [
    'addr_interval',
    'agraph',
    'analysis_block',
    'analysis_cc',
    'analysis_class_graph',
    'analysis_coverage',
    'analysis_function',
    'analysis_hints',
    'analysis_meta',
    'analysis_op',
    'analysis_var',
    'analysis_xrefs',
    'annotated_code',
    'base16',
    'base32',
    'base36',
    'base64',
    'base85',
    'big',
    'bin_lines',
    'bin_mach0',
    'bitvector',
    'bits',
    'marks',
    'buf',
    'cmd',
    'compare',
    'config',
    'cons',
    'contrbtree',
    'core_analysis_stats',
    'core_bin',
    'core_cmd',
    'core_seek',
    'core_task',
    'crypto',
    'debruijn',
    'debug',
    'debug_session',
    'diff',
    'ebcdic',
    'endian',
    'encodings',
    'event',
    'file',
    'flags',
    'flirt',
    'float',
    'glob',
    'graph',
    'hash',
    'hex',
    'ht',
    'id_storage',
    'idpool',
    'idstorage',
    'inflate_deflate',
    'il_definitions',
    'il_reg',
    'il_validate',
    'il_vm',
    'il_helpers',
    'intervaltree',
    'io',
    'io_ihex',
    'itv',
    'json',
    'list',
    'log',
    'lzma',
    'mem',
    'ovf',
    'pj',
    'rbtree',
    'reg',
    'regex',
    'rop',
    'rop_constraint',
    'run',
    'rz_test',
    'sdb_array',
    'sdb_diff',
    'sdb_sdb',
    'sdb_util',
    'serialize_analysis',
    'serialize_mark',
    'serialize_config',
    'serialize_debug',
    'serialize_flag',
    'serialize_seek',
    'serialize_spaces',
    'serialize_types',
    'skiplist',
    'skyline',
    'socket',
    'spaces',
    'sparse',
    'stack',
    'str',
    'strbuf',
    'str_search',
    'subprocess',
    'syscall',
    'table',
    'task',
    'threads',
    'tokens',
    'tree',
    'type',
    'uleb128',
    'unum',
    'util',
    'vector',
    'yank',
  ]

  unit_test_env = environment()
  if test_env_common_path != []
    unit_test_env.prepend('PATH', test_env_common_path)
  endif

  foreach test : tests
    exe = executable('test_@0@'.format(test), 'test_@0@.c'.format(test),
      include_directories: [platform_inc, '.'],
      dependencies: [
        rz_util_dep,
        rz_main_dep,
        rz_socket_dep,
        rz_core_dep,
        rz_io_dep,
        rz_bin_dep,
        rz_flag_dep,
        rz_cons_dep,
        rz_arch_dep,
        rz_debug_dep,
        rz_config_dep,
        rz_reg_dep,
        rz_syscall_dep,
        rz_type_dep,
        rz_egg_dep,
        rz_search_dep,
        rz_hash_dep,
        rz_crypto_dep,
        rz_magic_dep,
        rz_il_dep,
        rz_mark_dep,
        lrt,
      ],
      install: false,
      install_rpath: rpath_exe,
      implicit_include_directories: false,
    )
    test(test, exe, workdir: join_paths(meson.current_source_dir(), '..'), env: unit_test_env, depends: [auxiliaries, types_files], suite: 'unit')
  endforeach
endif
